﻿using System;
using System.Collections.Generic;
using System.Text;

using Kiiro.Common.Interfaces;

namespace Kiiro.Common.Entities
{
    [Serializable]
    public class Setup : BaseEntity, IEntity
    {
        #region Private Properties

        private string siteName;
        private List<ValidationMessage> siteNameMessage = new List<ValidationMessage> ( );
        private bool sendEmailUpdates = true;
        private List<ValidationMessage> sendEmailUpdatesMessage = new List<ValidationMessage> ( );
        private bool allowEmailReplies;
        private List<ValidationMessage> allowEmailRepliesMessage = new List<ValidationMessage> ( );
        private string emailFromAddress;
        private List<ValidationMessage> emailFromAddressMessage = new List<ValidationMessage> ( );
        private string smtpInfo;
        private List<ValidationMessage> smtpInfoMessage = new List<ValidationMessage> ( );
        private string popInfo;
        private List<ValidationMessage> popInfoMessage = new List<ValidationMessage> ( );
        private string popEmail;
        private List<ValidationMessage> popEmailMessage = new List<ValidationMessage> ( );
        private string popPassword;
        private List<ValidationMessage> popPasswordMessage = new List<ValidationMessage> ( );
        private string licenseKey;
        private List<ValidationMessage> licenseKeyMessage = new List<ValidationMessage> ( );
        private byte [ ] logoBytes;
        private List<ValidationMessage> logoBytesMessage = new List<ValidationMessage> ( );
        private string logoUrl;
        private List<ValidationMessage> logoUrlMessage = new List<ValidationMessage> ( );
        private float syncIntervalHours;
        private List<ValidationMessage> syncIntervalHoursMessage = new List<ValidationMessage> ( );
        private bool msProjectIntegration;
        private List<ValidationMessage> msProjectIntegrationMessage = new List<ValidationMessage> ( );
        private Version minMSProjectPluginVer;
        private List<ValidationMessage> minMSProjectPluginVerMessage = new List<ValidationMessage> ( );
        private double hoursPerDay = 8.0;
        private List<ValidationMessage> hoursPerDayMessage = new List<ValidationMessage> ( );
        private bool isWPSandboxActivated;
        private List<ValidationMessage> isWPSandboxActivatedMessage = new List<ValidationMessage> ( );
        private string wpSandboxNavText;
        private List<ValidationMessage> wpSandboxNavTextMessage = new List<ValidationMessage> ( );

        #endregion

        #region Public Properties

        public string SiteName
        {
            get { return siteName; }
            set
            {
                if ( siteName != value )
                {
                    siteName = value;
                    UpdateEntity ( );
                }
            }
        }

        public bool SendEmailUpdates
        {
            get { return sendEmailUpdates; }
            set
            {
                if ( sendEmailUpdates != value )
                {
                    sendEmailUpdates = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> SendEmailUpdatesMessage
        {
            get { return sendEmailUpdatesMessage; }
            set
            {
                if ( sendEmailUpdatesMessage != value )
                {
                    sendEmailUpdatesMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public bool AllowEmailReplies
        {
            get { return allowEmailReplies; }
            set
            {
                if ( allowEmailReplies != value )
                {
                    allowEmailReplies = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> AllowEmailRepliesMessage
        {
            get { return allowEmailRepliesMessage; }
            set
            {
                if ( allowEmailRepliesMessage != value )
                {
                    allowEmailRepliesMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public string EmailFromAddress
        {
            get { return emailFromAddress; }
            set
            {
                if ( emailFromAddress != value )
                {
                    emailFromAddress = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> EmailFromAddressMessage
        {
            get { return emailFromAddressMessage; }
            set
            {
                if ( emailFromAddressMessage != value )
                {
                    emailFromAddressMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public string SMTPInfo
        {
            get { return smtpInfo; }
            set
            {
                if ( smtpInfo != value )
                {
                    smtpInfo = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> SMTPInfoMessage
        {
            get { return smtpInfoMessage; }
            set
            {
                if ( smtpInfoMessage != value )
                {
                    smtpInfoMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public string POPInfo
        {
            get { return popInfo; }
            set
            {
                if ( popInfo != value )
                {
                    popInfo = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> POPInfoMessage
        {
            get { return popInfoMessage; }
            set
            {
                if ( popInfoMessage != value )
                {
                    popInfoMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public string POPEmail
        {
            get { return popEmail; }
            set
            {
                if ( popEmail != value )
                {
                    popEmail = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> POPEmailMessage
        {
            get { return popEmailMessage; }
            set
            {
                if ( popEmailMessage != value )
                {
                    popEmailMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public string POPPassword
        {
            get { return popPassword; }
            set
            {
                if ( popPassword != value )
                {
                    popPassword = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> POPPasswordMessage
        {
            get { return popPasswordMessage; }
            set
            {
                if ( popPasswordMessage != value )
                {
                    popPasswordMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> SiteNameMessage
        {
            get { return siteNameMessage; }
            set
            {
                if ( siteNameMessage != value )
                {
                    siteNameMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public string LicenseKey
        {
            get { return licenseKey; }
            set
            {
                if ( licenseKey != value )
                {
                    licenseKey = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> LicenseKeyMessage
        {
            get { return licenseKeyMessage; }
            set
            {
                if ( licenseKeyMessage != value )
                {
                    licenseKeyMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public byte [ ] LogoBytes
        {
            get { return logoBytes; }
            set
            {
                if ( logoBytes != value )
                {
                    logoBytes = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> LogoBytesMessage
        {
            get { return logoBytesMessage; }
            set
            {
                if ( logoBytesMessage != value )
                {
                    logoBytesMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public string LogoUrl
        {
            get { return logoUrl; }
            set
            {
                if ( logoUrl != value )
                {
                    logoUrl = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> LogoUrlMessage
        {
            get { return logoUrlMessage; }
            set
            {
                if ( logoUrlMessage != value )
                {
                    logoUrlMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public float SyncIntervalHours
        {
            get { return syncIntervalHours; }
            set
            {
                if ( syncIntervalHours != value )
                {
                    syncIntervalHours = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> SyncIntervalHoursMessage
        {
            get { return syncIntervalHoursMessage; }
            set
            {
                if ( syncIntervalHoursMessage != value )
                {
                    syncIntervalHoursMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public bool MSProjectIntegration
        {
            get { return msProjectIntegration; }
            set
            {
                if ( msProjectIntegration != value )
                {
                    msProjectIntegration = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> MSProjectIntegrationMessage
        {
            get { return msProjectIntegrationMessage; }
            set
            {
                if ( msProjectIntegrationMessage != value )
                {
                    msProjectIntegrationMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public Version MinMSProjectPluginVer
        {
            get { return minMSProjectPluginVer; }
            set
            {
                if ( minMSProjectPluginVer != value )
                {
                    minMSProjectPluginVer = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> MinMSProjectPluginVerMessage
        {
            get { return minMSProjectPluginVerMessage; }
            set
            {
                if ( minMSProjectPluginVerMessage != value )
                {
                    minMSProjectPluginVerMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public double HoursPerDay
        {
            get { return hoursPerDay; }
            set
            {
                if ( hoursPerDay != value )
                {
                    hoursPerDay = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> HoursPerDayMessage
        {
            get { return hoursPerDayMessage; }
            set
            {
                if ( hoursPerDayMessage != value )
                {
                    hoursPerDayMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public bool IsWPSandboxActivated
        {
            get { return isWPSandboxActivated; }
            set
            {
                if ( isWPSandboxActivated != value )
                {
                    isWPSandboxActivated = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> IsWPSandboxActivatedMessage
        {
            get { return isWPSandboxActivatedMessage; }
            set
            {
                if ( isWPSandboxActivatedMessage != value )
                {
                    isWPSandboxActivatedMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        public string WPSandboxNavText
        {
            get { return wpSandboxNavText; }
            set
            {
                if ( wpSandboxNavText != value )
                {
                    wpSandboxNavText = value;
                    UpdateEntity ( );
                }
            }
        }

        public List<ValidationMessage> WPSandboxNavTextMessage
        {
            get { return wpSandboxNavTextMessage; }
            set
            {
                if ( wpSandboxNavTextMessage != value )
                {
                    wpSandboxNavTextMessage = value;
                    UpdateEntity ( );
                }
            }
        }

        #endregion

        #region IEntity Members

        public new bool IsValid ( )
        {
            return AllValidationErrors ( ).Count == 0 && base.LicenseKeyErrorMessages.Count == 0;
        }

        public new List<ValidationMessage> AllValidationErrors ( )
        {
            List<ValidationMessage> allErrors = new List<ValidationMessage> ( );

            allErrors.AddRange ( SiteNameMessage );
            allErrors.AddRange ( SendEmailUpdatesMessage );
            allErrors.AddRange ( AllowEmailRepliesMessage );
            allErrors.AddRange ( EmailFromAddressMessage );
            allErrors.AddRange ( SMTPInfoMessage );
            allErrors.AddRange ( POPInfoMessage );
            allErrors.AddRange ( POPEmailMessage );
            allErrors.AddRange ( POPPasswordMessage );
            allErrors.AddRange ( LicenseKeyMessage );
            allErrors.AddRange ( LogoBytesMessage );
            allErrors.AddRange ( LogoUrlMessage );
            allErrors.AddRange ( SyncIntervalHoursMessage );
            allErrors.AddRange ( MSProjectIntegrationMessage );
            allErrors.AddRange ( MinMSProjectPluginVerMessage );
            allErrors.AddRange ( HoursPerDayMessage );
            allErrors.AddRange ( IsWPSandboxActivatedMessage );
            allErrors.AddRange ( WPSandboxNavTextMessage );

            return allErrors;
        }

        public new void ClearValidationMessages ( )
        {
            SiteNameMessage.Clear ( );
            SendEmailUpdatesMessage.Clear ( );
            AllowEmailRepliesMessage.Clear ( );
            EmailFromAddressMessage.Clear ( );
            SMTPInfoMessage.Clear ( );
            POPInfoMessage.Clear ( );
            POPEmailMessage.Clear ( );
            POPPasswordMessage.Clear ( );
            LicenseKeyMessage.Clear ( );
            LogoBytesMessage.Clear ( );
            LogoUrlMessage.Clear ( );
            SyncIntervalHoursMessage.Clear ( );
            MSProjectIntegrationMessage.Clear ( );
            MinMSProjectPluginVerMessage.Clear ( );
            LicenseKeyErrorMessages.Clear ( );
            HoursPerDayMessage.Clear ( );
            IsWPSandboxActivatedMessage.Clear ( );
            WPSandboxNavTextMessage.Clear ( );
        }

        #endregion
    }
}

/*************************************************************************
 * 
 * $Log: /Internal Projects/Kiiro/Kiiro.Common/Entities/Setup.cs $
 * 
 * 4     17/08/09 10:38a Camerons
 * Added check-in comments section
 * 
 ************************************************************************/